Definitions.
D = [0-9]
D1 = [1-9]
Rules.
[\s\t\r\n]+ : skip_token.
{  : {token, {'{', TokenLine}}.
}  : {token, {'}', TokenLine}}.
\[ : {token, {'[', TokenLine}}.
\] : {token, {']', TokenLine}}.
\: : {token, {':', TokenLine}}.
,  :   {token, {',', TokenLine}}.
null  :  {token, {constant, TokenLine, undefined}}.
true  :  {token, {constant, TokenLine, true}}.
false : {token, {constant, TokenLine, false}}.
(\+|\-)?(0|{D1}{D}*) :
	{token, {number, TokenLine, list_to_integer(TokenChars)}}.
(\+|\-)?(0|{D1}{D}*)\.{D}+((e|E)(\+|\-)?{D1}{D}*)? :
	{token, {number, TokenLine, element(1, string:to_float(TokenChars))}}.
"[^"]*" :
	{token, {string, TokenLine, lists:sublist(TokenChars, 2, TokenLen - 2)}}.

Erlang code.
